package com.atguigu.system.service.impl;

import com.atguigu.system.mapper.SupplierManagementMapper;
import com.atguigu.system.model.entity.SupplierManagement;
import com.atguigu.system.service.SupplierManagementService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2025-03-01
 */
@Service
public class SupplierManagementServiceImpl extends ServiceImpl<SupplierManagementMapper, SupplierManagement> implements SupplierManagementService {

    @Override
    public Page<SupplierManagement> pageQuery(Page<SupplierManagement> page, String supplierName, String cooperationStatus, String contactPhone) {
        LambdaQueryWrapper<SupplierManagement> queryWrapper = new LambdaQueryWrapper<>();
        if (supplierName != null && !supplierName.trim().isEmpty()) {
            queryWrapper.like(SupplierManagement::getSupplierName, supplierName);
        }

        if (cooperationStatus != null && !cooperationStatus.trim().isEmpty()) {
            queryWrapper.like(SupplierManagement::getCooperationStatus, cooperationStatus);
        }

        if (contactPhone != null && !contactPhone.trim().isEmpty()) {
            queryWrapper.like(SupplierManagement::getContactPerson, contactPhone);
        }
        return baseMapper.selectPage(page, queryWrapper);
    }
}
